import os
import json
import pathlib
from typing import List


class Repo:
    path: str


class Config:
    repos: List[Repo]


def read_config():
    config = pathlib.Path.home() / ".config" / "push_all" / "config.json"
    data = json.loads(config.read_text())
    return data


def main():
    config = read_config()
    repos = config["repos"]
    for r in repos:
        path = r["path"]
        print(">>>> git pull command")
        os.chdir(path)
        os.system("git pull")
        print(">>>> git push")
        os.chdir(path)
        os.system("git push")
        print(f">>>> {path} pushed")


if __name__ == "__main__":
    main()
